# 测试后台登录用例
import pytest

from config import BaseDir
from page.BackPage.PageHome import HomeProxy
from page.BackPage.PageLogin import LoginProxy
from utils import UtilsDriver, get_case_data

login_data = get_case_data(BaseDir + "/data/BackJson/login.json")


@pytest.mark.run(order=1001)
class TestBackLogin:
    # 定义类级别的fixture初始化方法
    def setup_class(self):
        self.login_proxy = LoginProxy()
        self.home_proxy = HomeProxy()

    #     定义类级别的fixture销毁方法
    def teardown_class(self):
        UtilsDriver.quit_back_driver()

    @pytest.mark.parametrize("username,password,expect", login_data)
    def test_login(self, username, password, expect):
        self.login_proxy.go_login(username, password)
        my_username = self.home_proxy.my_username()
        assert expect in my_username
